
Global Game:String
Global GamePath:String
Global EID:Int
Global MainED:MainEditor
 
Rem
Const genMaxHeroPic   	= 40
Const genMaxEnemy1Pic 	= 149
Const genMaxEnemy2Pic 	= 79
Const genMaxEnemy3Pic	= 29
Const genMaxNPCPic		= 119
Const genMaxWeaponPic 	= 149
Const genMaxAttackPic	= 99
Const genMaxTile      	= 33
Const genMaxAttack    	= 200
Const genMaxHero      	= 59
Const genMaxEnemy     	= 500
Const genMaxFormation 	= 1000
Const genMaxPal       	= 99
Const genMaxTextbox   	= 999
Const genMaxBoxBorder = 83
Const genMaxPortrait = 84
End Rem

Const genMaxHeroPic = 26        'max hero graphic number in .PT0
Const genMaxEnemy1Pic = 27      'max small enemy graphic number in .PT1
Const genMaxEnemy2Pic = 28      'max medium enemy graphic number in .PT2
Const genMaxEnemy3Pic = 29      'max large enemy graphic number in .PT3
Const genMaxNPCPic = 30         'max npc graphic number in .PT4
Const genMaxWeaponPic = 31      'max weapon graphic number in .PT5
Const genMaxAttackPic = 32      'max attack graphic number in .PT6
Const genMaxTile = 33           'max tileset number in .TIL
Const genMaxAttack = 34         'max attack definition number in .DT6
Const genMaxHero = 35           'max hero definition number in .DT0
Const genMaxEnemy = 36          'max enemy definition number in .DT1
Const genMaxFormation = 37      'max formation number in .FOR
Const genMaxPal = 38            'max palette number in .PAL
Const genMaxTextbox = 39        'max text box number in .SAY
Const genNumPlotscripts = 40    'number of scripts of any kind (number of records in PLOTSCR.LST)
Const genNewGameScript = 41     'id of new-game plotscript
Const genGameoverScript = 42    'id of game-over plotscript
Const genMaxRegularScript = 43  'id of highest numbered non-autonumbered plotscript
Const genSuspendBits = 44       'suspend stuff bits (suspend* constants in scrconst.bi)
Const genCamera = 45            'camera mode
Const genCamArg1 = 46           'cameraarg1
Const genCamArg2 = 47           'cameraarg2
Const genCamArg3 = 48           'cameraarg3
Const genCamArg4 = 49           'cameraarg4
Const genScrBackdrop = 50       'currently displaying script backdrop in .MXS + 1, 0 for none
Const genDays = 51              'days of play
Const genHours = 52             'hours of play
Const genMinutes = 53           'minutes of play
Const genSeconds = 54           'seconds of play
Const genMaxVehicle = 55        'max vehicle type number in .VEH
Const genMaxTagname = 56        'last named tag
Const genLoadGameScript = 57    'load-game script
Const genTextboxBackdrop = 58   'currently displaying text box backdrop in .MXS + 1, 0 for none
Const genEnemyDissolve = 59     'Default dissolve animation for dying enemies
Const genJoy = 60               'whether the joystick is enabled (not respected in many places, especially waitforanykey)
Const genPoison = 61            'poison status indicator char
Const genStun = 62              'Stun status indicator char
Const genDamageCap = 63         'Damage cap
Const genMute = 64              'Mute status indicator char
Const genStatCap = 65           'Stat caps (genStatCap + stat) (65-76)
Const genMaxSFX = 77            'last song number
Const genMasterPal = 78         'master palette number
Const genMaxMasterPal = 79      'max master palette number
Const genMaxMenu = 80           'max menu def in MENUS.BIN
Const genMaxMenuItem = 81       'max menu item def in MENUITEM.BIN
Const genMaxItem = 82           'max item in .ITM
Const genMaxBoxBorder = 83      'max box border number in .PT7
Const genMaxPortrait = 84       'max portrait graphic number in .PT8
Const genMaxInventory = 85      'max available inventory slot (0 means use inventoryMax)
Const genErrorLevel = 86        'value to set err_suppress_lvl to, if nonzero
Const genLevelCap = 87          'Default maximum level (0 to genMaxLevel) (not to be confused with genMaxLevel)
Const genEquipMergeFormula = 88 'Formula to use to calculate effective hero elemental resists
Const genNumElements = 89       'Number of elements used
Const genUnlockedReserveXP = 90 '% experience gained by unlocked reserve heroes
Const genLockedReserveXP = 91   '% experience gained by locked reserve heroes
Const genPW4Hash = 92           'new (4th style) password hash
Const genPW2Offset = 93         'old-old password offset
Const genPW2Length = 94         'old-old password length
Const genVersion = 95           'RPG file format version (see CURRENT_RPG_VERSION above for latest)
Const genStartMoney = 96        'starting money
Const genMaxShop = 97           'last shop in .SHO
Const genPW1Offset = 98         'old-old-old password offset
Const genPW1Length = 99         'old-old-old password length
Const genNumBackdrops = 100     'number of screens in .MXS
Const genBits = 101             'general bitsets
Const genStartX = 102           'starting X
Const genStartY = 103           'starting Y
Const genStartMap = 104         'starting Map
Const genOneTimeNPC = 105       'one-time-NPC indexer
Const genOneTimeNPCBits = 106   'one-time-NPC bits start here, OBSOLETE!
Const genDefaultDeathSFX = 171  'default enemy death sound effect
Const genMaxSong = 172          'last song number
Const genAcceptSFX = 173        'menu interface
Const genCancelSFX = 174        ' "       "
Const genCursorSFX = 175        ' "       "
Const genTextboxLine = 176      'Text box 'click'
Const genBits2 = 177            'More general bitsets
Const genBits3 = 178            'More general bitsets
Const genItemLearnSFX = 179     'learn spell oob item
Const genCantLearnSFX = 180     'hero couldn't learn spell from item
Const genBuySFX = 181           'buy item from shop
Const genHireSFX = 182          'hire from shop
Const genSellSFX = 183          'sell item to shop
Const genCantBuySFX = 184       'can't afford item/hire
Const genCantSellSFX = 185      'unsellable item
Const genDamageDisplayTicks = 186 'number of ticks that battle damage displays
Const genDamageDisplayRise = 187 'number of pixels that damage display rises
Const genHeroWeakHP = 188       '%HP for heroes to use Weak state
Const genEnemyWeakHP = 189      '%HP for enemies to use Desperation AI
Const genAutosortScheme = 190   'Method used to autosort inventory
Const genMaxLevel = 191         'Maximum level (not to be confused with changeable genLevelCap)
Const genBattleMode = 192       'Battle mode 0=Active-time, 1=Turn-based
Const genItemStackSize = 193    'Default item stack size
Const genResolutionX = 194      'Screen resolution (unzoomed). 0 for default
Const genResolutionY = 195      ' "

'--- Binary files in BINSIZE.BIN for getbinsize()
Const binATTACK = 0
Const binSTF = 1
Const binSONGDATA = 2
Const binSFXDATA = 3
Const binMAP = 4
Const binMENUS = 5
Const binMENUITEM = 6
Const binUICOLORS = 7
Const binSAY = 8
Const binN = 9
Const binDT0 = 10
Const binDT1 = 11
Const binITM = 12
Const sizebinsize = 12 ' *** Update this when adding binsize records ***


'---Sizes (replaceable with variables when suitable)
Const max_npc_defs = 500 'max number of NPC IDs definable in Custom
Const maxMaxItems = 32000 'max number of items
Const maxMaxHero = 59 'This is the max value possible for gen(genMaxHero) 'FIXME: not used everywhere
Const inventoryMax = 599 'last inventory slot num (divisible by 3 when you count the zero)
Const maplayerMax = 7 'The limit on the highest numbered map layer
Const mapTilesMax = 100000 'Maximum map size, in tiles (note also a limit of 32768 tiles wide or high)
Const dissolveTypeMax = 10 'Highest numbered frame dissolve effect
Const maxElements = 64 'Maximum selectable number of elements
Const tempZone = 10000 'ID (and up) to use for temporary zones
Const maxMapHistoryMem = 1000000 'In number of MapEditUndoTiles (8 bytes)
Const maxScriptGlobals = 16383 'Actually the index of the last global
Const maxScriptStrings = 99 'ID of last plotstring
Const maxScriptHeap = 8192 'Maximum number of local variables in use by all running scripts
Const maxScriptRunning = 128 'Number of scripts which can run at once

Global WalkaboutState:SpriteState
Global HeroState:SpriteState
Global SmallEnemyState:SpriteState
Global MediumEnemyState:SpriteState
Global LargeEnemyState:SpriteState
Global AttackState:SpriteState
Global WeaponState:SpriteState
Global BoxState:SpriteState
Global PortraitState:SpriteState
Global TileSState:TilsetState
Global MusicState:SongState
Global SFXState:SoundState
Global Maps:TList = New TList 'Since there is no Set Maximum maps we need to use a list

Global BackdropSet:BackdropState

Global RPGLump:FileLump
Global MasterPalette:Palette256[256]
Global DefPalette:Palette256[256] 
MasterPalette[0] = New Palette256
MasterPalette[0].col[0] = 0

For Local i:Int = 1 To 15

	MasterPalette[0].col[i] = ARGB(255,Rand(0,255),Rand(0,255),Rand(0,255))

Next

Rem
Global genStartX
Global genStartY
Global genStartMap
Global genStartMoney
End Rem

Global Gen:Int[360]

Global proc:TProcess